home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 342_01.zip / I8255F02.C < prev    next >
C/C++ Source or Header  |  1993-04-03  |  2KB  |  56 lines

  1. /*-
  2.  *  ----------------------------------------------------------------------
  3.  *  File        :   I8255F02.C
  4.  *  Creator     :   Blake Miller
  5.  *  Version     :   01.00.00        February 1991
  6.  *  Language    :   Microsoft C     Version 5.1
  7.  *  Purpose     :   Intel 8255 Compatible Digital IO Functions
  8.  *              :   Set 8255 Mode Function
  9.  *  ----------------------------------------------------------------------
  10.  */
  11.  
  12. #define  I8255F02_C_DEFINED  1
  13. #include "I8255FN.H"
  14. #undef   I8255F02_C_DEFINED
  15.  
  16. void I8255_config (I8255DAT *data, int pa_dir, int pb_dir,
  17.                                    int cl_dir, int ch_dir);
  18.  
  19. /*- I8255 : Configure ------------------------**
  20.  *  Configure the 8255 for all ports in Mode 0.
  21.  *  Pass an integer representing the IN or OUT state for each port.
  22.  *  TRUE (!0) will mean input, and FALSE (0) will mean output.
  23.  *  Passed:
  24.  *      pointer :   I8255DAT
  25.  *      integer :   direction Port A
  26.  *      integer :   direction Port B
  27.  *      integer :   direction Port C Low
  28.  *      integer :   direction Port C High
  29.  *  Returns:
  30.  *      nothing
  31.  */
  32. void I8255_config (I8255DAT *data, int pa_dir, int pb_dir,
  33.                                    int cl_dir, int ch_dir )
  34.     {
  35.  
  36.     /*  Initially set mode to I8255_SET since we are
  37.      *  going to configure the 8255.
  38.      *  Then OR in the IO direction bits as appropriate.
  39.      */
  40.  
  41.     data->mode = I8255_SET;
  42.  
  43.     if ( pa_dir )   data->mode |= I8255_PA_IN;
  44.     if ( pb_dir )   data->mode |= I8255_PB_IN;
  45.     if ( cl_dir )   data->mode |= I8255_CL_IN;
  46.     if ( ch_dir )   data->mode |= I8255_CH_IN;
  47.     chp_portwt ( I8255_CNTRL(data->base), data->mode );
  48.     data->stat = I8255_ST_OK;
  49.     }
  50.  
  51. /*-
  52.  *  ----------------------------------------------------------------------
  53.  *  END I8255F02.C Source File
  54.  *  ----------------------------------------------------------------------
  55.  */
  56.